package com.io.stream.iobyte;

import com.io.stream.IoParam;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class IoByte01 {
    public static void main(String[] args) throws Exception {
        // 源文件 目标文件
        File source = new File(IoParam.BASE_PATH+"fileio-01.png") ;
        File target = new File(IoParam.BASE_PATH+"copy-"+source.getName()) ;
        // 输入流 输出流
        InputStream inStream = new FileInputStream(source) ;
        OutputStream outStream = new FileOutputStream(target) ;
        // 读入 写出
        byte[] byteArr = new byte[1024];
        int readSign ;
        while ((readSign=inStream.read(byteArr)) != -1){
            outStream.write(byteArr);
        }
        // 关闭输入、输出流
        outStream.close();
        inStream.close();
    }
}
